package fingerguessinggame;

import java.net.SocketTimeoutException;

public class FingerGuessing {
    private Computer computer = new Computer();
    private Player player = new Player();
    public static int total = 0;

    public static void main(String[] args) {
        //测试电脑
//        Computer computer = new Computer();

        //测试玩家
//        Player player =new Player();

        FingerGuessing fingerGuessing = new FingerGuessing();
        fingerGuessing.battle();
    }


    public void battle() {
        for (int i = 0; i < 10; i++) {
            //电脑数字
            int computerNum = computer.showfist();
            System.out.println(computerNum);

            //玩家数字
            int playerNum = player.showfist();
            System.out.println(playerNum);

            //请输入数字：1—剪刀 2—石头 3—布
            int win = 0, dogfall = 0, lose = 0;

            if (computerNum == playerNum) {
                System.out.println("请输入数字：1—剪刀 2—石头 3—布");
                System.out.println("平局，你输入的是:" + playerNum + "\t电脑输入的是:" + computerNum);
                dogfall++;
            } else if (playerNum == 1 && computerNum == 3 || playerNum == 2 && computerNum == 1 || playerNum == 3 && computerNum == 2) {
                System.out.println("请输入数字：1—剪刀 2—石头 3—布");
                System.out.println("恭喜您赢下一局，您输入的是：" + playerNum + "\t电脑输入的是" + computerNum);
                win += 3;
            } else {
                System.out.println("请输入数字：1—剪刀 2—石头 3—布");
                System.out.println("很遗憾您输了这一局，您输入的是：" + playerNum + "\t电脑输入的是" + computerNum);
                lose -= 3;
            }
            total = win + dogfall + lose;
            System.out.println("您当前得分为" + total);
        }
        if (total > 0) {
            System.out.println("恭喜您获胜了");
        } else {
            System.out.println("you died");
        }
    }

}
